Skip to content

[#957] Lifecycle-aware cleanup of agent backend temp dirs#960

Open
realproject7 wants to merge 1 commit into
mainfrom
task/957-backend-temp-cleanup
Open

[#957] Lifecycle-aware cleanup of agent backend temp dirs#960
realproject7 wants to merge 1 commit into
mainfrom
task/957-backend-temp-cleanup

Conversation

@realproject7

Copy link
Copy Markdown
Owner

Fixes #957

What

Adds server/temp-cleanup.js — a stale-only sweep of agent backend temp — wired into two lifecycle points in server/index.js:

  • Agent teardown (stopAgentSession): deferred fire-and-forget sweep after every stop/reset/restart.
  • Periodic: hourly timer + one sweep at boot (a server that was down for days reclaims quota immediately).

Targets (confirmed on the VPS that hit #957):

  • /tmp/claude-{uid} — Claude Code's unbounded TMPDIR override (the 909 MB / 63k-inode quota killer).
  • /tmp/gemini-client-error-*.json — stray Gemini crash dumps (observed on the VPS).
  • Codex: confirmed no /tmp usage (state lives in ~/.codex) → nothing to sweep.

Safety design

Docs

  • docs/troubleshooting.md: new section for the silent-exit-1 symptom (it masquerades as a sandbox failure) with diagnosis + manual recovery.
  • docs/install-vps.md: note about usrquota VPS images.

Verification

  • New server/temp-cleanup.test.js: stale file/dir removed (recursively), fresh spared, claude dir itself kept, gemini dumps matched, unrelated old files never touched, missing dir / Windows-no-uid / bogus root → clean no-op, settings defaults + opt-out. All fixture-based with injected uid/now/tmpRoot — never touches the real /tmp.
  • Full suite: 53 passed, 0 failed · node --check both files · boot smoke (QUADWORK_SKIP_LISTEN=1 require) OK · npm run build OK.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lifecycle-aware cleanup of agent backend temp dirs (/tmp/claude-{uid}) to prevent /tmp quota exhaustion

1 participant